//
//  BPButton.swift
//  BPWeiBo
//
//  Created by apple on 16/4/12.
//  Copyright © 2016年 apple. All rights reserved.
//

import UIKit
//自定义UIBUtton的构造方法
extension UIButton {
    convenience init(title: String,count: Int,imgName: String) {
        self.init()
        
        //let btn = UIButton(type: .Custom)
        self.setImage(UIImage(named: imgName), forState: .Normal)
        
        if count > 0 {
            self.setTitle("\(count)", forState: .Normal)
        } else {
            self.setTitle("\(title)\(count)", forState: .Normal)
        }
        
        self.setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
        self.setBackgroundImage(UIImage(named: "timeline_card_middle_background_highlighted"), forState: .Highlighted)
        self.setBackgroundImage(UIImage(named: "timeline_card_middle_background"), forState: .Normal)
        self.titleLabel?.font = UIFont.systemFontOfSize(12)
        sizeToFit()
    }

}